// stores/counter.js
import { defineStore } from 'pinia';

export const useCounterStore = defineStore('counter', {
	state: () => ({
	  count: 0,
	  name: 'Vue 3 + Pinia',
	}),
	getters: {
	  doubleCount: (state) => state.count * 2,
	},
	actions: {
	  increment() {
		this.count++;
	  },
	  reset() {
		this.count = 0;
	  },
	},
	persist: {
	  enabled: true, // 开启持久化
	  strategies: [
		{
		  key: 'counter', // 存储的键名
		  storage: localStorage, // 存储位置，可以是 localStorage 或 sessionStorage
		},
	  ],
	},
  });